<script lang="ts" setup>
import { onMounted, ref, nextTick } from 'vue'
// import gdgnpz from './tabs/gdgnpz.vue'
import sypz from './tabs/sypz.vue'
import bypz from './tabs/bypz.vue'
import { useMainStore } from '@/store/main'
// import sjbdcpz from './tabs/sjbdcpz.vue'

const store = useMainStore()

onMounted(() => {
  if (store.userInfo.dwbm === '310000') {
    activeName.value = 'bypz'
    changeTabs(activeName.value)
  } else {
    activeName.value = 'sypz'
    changeTabs(activeName.value)
  }
})
// 入参
const activeName = ref<string>('sypz')
// ref
// const gdgnpzRef = ref<InstanceType<typeof gdgnpz>>()
const sypzRef = ref<InstanceType<typeof sypz>>()
const bypzRef = ref<InstanceType<typeof bypz>>()
// const sjbdcpzRef = ref<InstanceType<typeof sjbdcpz>>()

/*
 * 切换tab页
 */
const changeTabs = (val: string) => {
  nextTick(() => {
    switch (val) {
      case 'sypz':
        sypzRef.value?.init()
        break
      case 'bypz':
        nextTick(() => {
          bypzRef.value?.init()
        })
        break
      // case 'gdgnpz':
      //   gdgnpzRef.value?.init()
      //   break
      // case 'sjbdcpz':
      //   sjbdcpzRef.value?.init()
      //   break
      default:
        break
    }
  })
}
</script>
<template>
  <div class="container">
    <el-tabs v-model="activeName" type="card" @tab-change="changeTabs">
      <!-- <el-tab-pane label="归档功能配置" name="gdgnpz" lazy>
        <gdgnpz ref="gdgnpzRef" />
      </el-tab-pane> -->
      <!-- 
      <el-tab-pane label="归档模板配置" name="gdmbpz" lazy>
        <gdmbpz ref="gdmbpzRef" />
      </el-tab-pane>
      <el-tab-pane label="归档范围配置" name="gdfwpz" lazy>
        <gdfwpz ref="gdfwpzRef" />
      </el-tab-pane> -->
      <!--   -->
      <el-tab-pane label="市院配置" name="sypz" v-if="store.userInfo.dwbm !== '310000'" lazy>
        <sypz ref="sypzRef" />
      </el-tab-pane>
      <el-tab-pane label="本院配置" name="bypz" lazy>
        <bypz ref="bypzRef" />
      </el-tab-pane>
      <!-- <el-tab-pane label="数据包导出配置" name="sjbdcpz" lazy>
        <sjbdcpz ref="sjbdcpzRef" />
      </el-tab-pane> -->
    </el-tabs>
  </div>
</template>
<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  background: #fff;
}
</style>
